cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/.")

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stried binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)

rosbuild_init()

IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
        FIND_LIBRARY(CARBON_LIBRARY Carbon)
        FIND_LIBRARY(IOKIT_LIBRARY IOKit)
        MARK_AS_ADVANCED (CARBON_LIBRARY IOKIT_LIBRARY)
        SET(EXTRA_LIBS ${CARBON_LIBRARY} ${IOKIT_LIBRARY})
        SET(EXTRA_SRC src/usbwrap_iokit.cc)
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
        find_package(LIBUSB REQUIRED)
        include_directories(${USB_INCLUDE_DIRS})
        SET(EXTRA_LIBS ${USB_LIBRARIES})
        SET(EXTRA_SRC  src/usbwrap_libusb.cc)
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows" OR )
		message(FATAL_ERROR "Windows is not yet supported")
        find_package(DDK REQUIRED)
        include_directories(${DDK_INCLUDE_DIRS})
        SET(EXTRA_LIBS ${DDK_LIBRARIES})
        SET(EXTRA_SRC  src/usbwrap_ddk.cc)
ENDIF ()

#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

rosbuild_add_library(owicontroller src/owicontroller.cc ${EXTRA_SRC})
TARGET_LINK_LIBRARIES(owicontroller ${EXTRA_LIBS})